<template>
  <div class="container mainCon">
    <el-tabs
      v-model="activeName"
      type="card"
      @tab-click="handleClick"
      class="commonTab"
    >
      <el-tab-pane label="非建领域" name="first">
        <patrolListFJ
          v-if="isShowFirst"
          :domain="domain"
          :taskType="taskType"
        ></patrolListFJ>
      </el-tab-pane>
      <el-tab-pane label="建筑领域" name="second">
        <patrolListJZ
          v-if="isShowSecond"
          :domain="domain"
          :taskType="taskType"
        ></patrolListJZ>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import patrolListFJ from '@/components/patrol/patrolListFJ'
import patrolListJZ from '@/components/patrol/patrolListJZ'

export default {
  name: 'patrolList',
  props: ['taskType'],
  components: {
    patrolListFJ,
    patrolListJZ,
  },
  data() {
    return {
      activeName: 'first',
      isShowFirst: true,
      isShowSecond: false,
      domain: 'FJ',
    }
  },
  created() {
    //建筑返回默认建筑tab选中
    this.activeName = this.$route.query.domain == 'JZ' ? 'second' : 'first'
    this.domain = this.$route.query.domain
    this.taskType = this.$route.query.taskType || this.taskType
    if (this.$route.query.domain === 'JZ') {
      this.isShowSecond = true
      // this.isShowFirst = false;
    } else {
      this.isShowFirst = true
      // this.isShowSecond = false;
    }
  },
  methods: {
    //tabs栏切换
    handleClick(tab, event) {
      if (tab.label == '非建领域') {
        this.isShowFirst = true
        // this.isShowSecond = false;
        this.domain = 'FJ'
        //  this.$router.push({
        //     query: {
        //         domain: this.domain
        //     },
        // });
      } else if (tab.label == '建筑领域') {
        this.isShowSecond = true
        // this.isShowFirst = false;
        this.domain = 'JZ'
        // this.$router.push({
        //     query: {
        //         domain: this.domain
        //     },
        // });
      }
    },
  },
}
</script>

<style scoped lang="less">
.mainCon {
  top: 130px;
  padding: 0;
}
</style>
